/*
 #
 #  Files       : SmallMatrix.h
 #                ( C++ header file )
 #
 #  Description : The SmallMatrix Library
 #                ( http://code.google.com/p/smallmatrix )
 #
 #  Copyright   : Olivier Juan
 #                ( http://www.mas.ecp.fr/vision/Personnel/juan/ )
 #
 #  License     : CeCILL-C
 #                ( http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html )
 #
 #  This software is governed by the CeCILL-C license under French law and
 #  abiding by the rules of distribution of free software.  You can  use,
 #  modify and or redistribute the software under the terms of the CeCILL-C
 #  license as circulated by CEA, CNRS and INRIA at the following URL
 #  "http://www.cecill.info".
 #
 #  As a counterpart to the access to the source code and  rights to copy,
 #  modify and redistribute granted by the license, users are provided only
 #  with a limited warranty  and the software's author,  the holder of the
 #  economic rights,  and the successive licensors  have only  limited
 #  liability.
 #
 #  In this respect, the user's attention is drawn to the risks associated
 #  with loading,  using,  modifying and/or developing or reproducing the
 #  software by the user in light of its specific status of free software,
 #  that may mean  that it is complicated to manipulate,  and  that  also
 #  therefore means  that it is reserved for developers  and  experienced
 #  professionals having in-depth computer knowledge. Users are therefore
 #  encouraged to load and test the software's suitability as regards their
 #  requirements in conditions enabling the security of their systems and/or
 #  data to be ensured and,  more generally, to use and operate it in the
 #  same conditions as regards security.
 #
 #  The fact that you are presently reading this means that you have had
 #  knowledge of the CeCILL-C license and that you accept its terms.
 #
*/

#ifndef _SMALLMATRIX_H
#define _SMALLMATRIX_H

#pragma inline_depth(255)
#pragma inline_recursion(on)

#include <cmath>
#include <cassert>

#if defined(WIN32) || defined(WIN64)
#undef INLINE
#define INLINE __forceinline
#else
#define INLINE inline
#endif

#define NAMESPACE_BEGIN(name) namespace name {
#define NAMESPACE_END };

NAMESPACE_BEGIN(SmallMatrix)

#ifndef USE_FLOATS

#ifndef _USE_FLOAT_
#define _SMALLMATRIX_USE_FLOAT_ 1
#endif

#if _USE_FLOAT_
	typedef float reel;		 //!< definition of reel (\c _USE_FLOAT_ = 1)
#define REEL_MAX FLT_MAX //!< definition of REEL_MAX (\ _USE_FLOAT_ = 1)
#define REEL_MIN FLT_MIN //!< definition of REEL_MIN (\ _USE_FLOAT_ = 1)
#define REEL_EPSILON FLT_EPSILON //!< definition of REEL_EPSILON (\ _USE_FLOAT_ = 1)
#else
	typedef double reel;		 //!< definition of reel (_USE_FLOAT_ = 0)
#define REEL_MAX DBL_MAX //!< definition of REEL_MAX (\ _USE_FLOAT_ = 1)
#define REEL_MIN DBL_MIN //!< definition of REEL_MIN (\ _USE_FLOAT_ = 1)
#define REEL_EPSILON DBL_EPSILON //!< definition of REEL_EPSILON (\ _USE_FLOAT_ = 1)

#endif
#else
	//typedef ::reel reel;
#endif

#if 1
//def __GNUC__
#define TPS_START_GCC(x) , typename TEMPLATE_PARTIAL_SPECIALIZATION_OF_NESTED_CLASS_##x = void
#define TPS_CONTINUE_GCC(x) , typename TEMPLATE_PARTIAL_SPECIALIZATION_OF_NESTED_CLASS_##x
#define TPS_END_GCC(x) typename TEMPLATE_PARTIAL_SPECIALIZATION_OF_NESTED_CLASS_##x
#define TPS_GCC(x) , TEMPLATE_PARTIAL_SPECIALIZATION_OF_NESTED_CLASS_##x
#else
#define TPS_START_GCC(x)
#define TPS_CONTINUE_GCC(x) 
#define TPS_END_GCC(x)
#define TPS_GCC(x)
#endif

template <typename T> class Matrix_Base;
template <int M,int N> class Matrix;
template <int N> class SquareMatrix;
template <int N> class SymMatrix;
template <typename T, int N> class Vector;


INLINE reel pythag(const reel& a, const reel& b)
{
	reel absa=std::abs(a),absb=std::abs(b);
	if (absa > absb) return absa*std::sqrt(1+(absb/absa)*(absb/absa));
	else return (absb == 0 ? 0 : absb*std::sqrt(1+(absa/absb)*(absa/absb)));
}

NAMESPACE_END

#include <iostream>
#include <sstream>
#include <SmallMatrix/DescriptionTraits.h>
//#include <SmallMatrix/Functors.h>
//#include <SmallMatrix/Results.h>
//#include <SmallMatrix/Action.h>
//#include <SmallMatrix/Expressions.h>
//#include <SmallMatrix/MiscTemplate.h>
#include <SmallMatrix/StaticAssert.h>
//#include <SmallMatrix/BinaryTraits.h>
#include <SmallMatrix/MatrixBase.h>
//#include <SmallMatrix/Matrix.h>
//#include <SmallMatrix/SquareMatrix.h>
//#include <SmallMatrix/SymMatrix.h>
#include <SmallMatrix/Vector.h>
//#include <SmallMatrix/SmallMatrixIO.h>

#undef INLINE

#endif
